﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;

public partial class CJMainPage : System.Web.UI.MasterPage
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly NewsBLL bllNews = new NewsBLL();
    private static readonly LinkBLL bllLink = new LinkBLL();
    private static readonly TravelLinesBLL bllTravelLines = new TravelLinesBLL();
    int rowCount = 0;
    public string Keywords;
    public string Description;
    public string Hlable;
    public string Curl;

    public TravelLines modelTemp = new TravelLines();
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                SetMeta();
                BindCityLable();
                BindHelp();
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }

    //旅游资讯
    public void BindHelp()
    {
        this.rptTravelHelp.DataSource = bllNews.GetListByShowType(15, 1, 2, out rowCount);
        rptTravelHelp.DataBind();

    }


    //导航文字
    public void BindCityLable()
    {
        string imgPic = "cjly.jpg";
        string MapPic = "nomap.jpg";
        Curl = "images/" + imgPic;
        //imgBanner.ImageUrl = "images/" + imgPic;
        if (!string.IsNullOrEmpty(Request.QueryString["PID"] + ""))
        {
            int key = int.Parse(Request.QueryString["PID"] + "");
            if (key > 0)
            {
                try
                {
                    lblCity.Text = bllCategory.GetModel(key).title;
                    XLTJControl1.TravelTypeCode = "cjly";
                    switch (lblCity.Text)
                    {
                        case "美洲旅游":
                            imgPic = "meiguo.jpg";
                            MapPic = "meizhou.jpg";
                            break;
                        case "欧洲旅游":
                            imgPic = "ouzhou.jpg";
                            MapPic = "ouzhou.jpg";
                            break;
                        case "澳洲旅游":
                            imgPic = "aozhou.jpg";
                            MapPic = "aozhou.jpg";
                            break;
                        case "中东非洲旅游":
                            imgPic = "Africa.jpg";
                            MapPic = "zhongdong.jpg";
                            break;
                        case "日韩旅游":
                            imgPic = "Japan.jpg";
                            MapPic = "rihan.jpg";
                            break;
                        case "东南亚旅游":
                            imgPic = "SoutheastAsia.jpg";
                            MapPic = "dongnaya.jpg";
                            break;
                        case "越南柬埔寨":
                            imgPic = "Vietnam.jpg";
                            MapPic = "dongnaya.jpg";
                            break;
                        case "马尔代夫":
                            imgPic = "mrdf.jpg";
                            MapPic = "maerdaifu.jpg";
                            break;
                        case "印度尼泊尔":
                            imgPic = "India.jpg";
                            MapPic = "yindu.jpg";
                            break;
                        default:
                            imgPic = "cjly.jpg";
                            break;
                    }
                }
                catch { }
            };
            //imgBanner.ImageUrl = "images/" + imgPic;
            Curl = "images/" + imgPic;
            XLTJControl1.MapImgUrl = MapPic;
        }
        else
        {
            try
            {
                SetPicByKey();
            }
            catch (Exception ex)
            {
                Curl = "images/" + imgPic;
                //imgBanner.ImageUrl = "images/" + imgPic;
            }
        }

    }

    public void SetPicByKey()
    {
        if (!string.IsNullOrEmpty(Request.QueryString["Key"] + ""))
        {
            string imgPic = "cjly.jpg";
            string MapPic = "nomap.jpg";
            int cityid = bllTravelLines.GetModel(int.Parse(Request.QueryString["Key"] + "")).endCity.Value;
            Category tempModel = bllCategory.GetModelList("id=" + bllCategory.GetModel(cityid).parentID)[0];
            if (tempModel != null)
            {
                lblCity.Text = tempModel.title;
                XLTJControl1.TravelTypeCode = "cjly";
                switch (tempModel.title)
                {
                    case "美洲旅游":
                        imgPic = "meiguo.jpg";
                        MapPic = "meizhou.jpg";
                        break;
                    case "欧洲旅游":
                        imgPic = "ouzhou.jpg";
                        MapPic = "ouzhou.jpg";
                        break;
                    case "澳洲旅游":
                        imgPic = "aozhou.jpg";
                        MapPic = "aozhou.jpg";
                        break;
                    case "中东非洲旅游":
                        imgPic = "Africa.jpg";
                        MapPic = "zhongdong.jpg";
                        break;
                    case "日韩旅游":
                        imgPic = "Japan.jpg";
                        MapPic = "rihan.jpg";
                        break;
                    case "东南亚旅游":
                        imgPic = "SoutheastAsia.jpg";
                        MapPic = "dongnaya.jpg";
                        break;
                    case "越南柬埔寨":
                        imgPic = "Vietnam.jpg";
                        MapPic = "dongnaya.jpg";
                        break;
                    case "马尔代夫":
                        imgPic = "mrdf.jpg";
                        MapPic = "maerdaifu.jpg";
                       break;
                    case "印度尼泊尔":
                        imgPic = "India.jpg";
                        MapPic = "yindu.jpg";
                        break;
                    default:
                        imgPic = "";
                        break;
                }

            }
            //imgBanner.ImageUrl = "images/" + imgPic;
            XLTJControl1.MapImgUrl = MapPic;
        }
    }
    public void SetMeta()
    {
        if (Request.QueryString["Key"] != null)
        {
            int Key = Int32.Parse(Request.QueryString["Key"].ToString());

            modelTemp = bllTravelLines.GetModel(Key);

            this.Keywords = "\"" + modelTemp.title + "\"";
            this.Description = "\"" + modelTemp.featureDes.Substring(0, 100) + "\"";
            this.Hlable = modelTemp.title;
        }
        else
        {

            this.Keywords = "\"成都出境旅游网,成都出境旅行,出国旅游团,国外热门旅游路线,出境旅行团,成都出境旅游,出境旅游手续,成都出境旅游咨询,出国旅游注意事项\"";
            this.Description = "\"下驿栈旅游网出境旅游频道为您提供最新最全的出国旅游信息,包括成都出境旅游线路与路线推荐,出国旅游注意事项、出国旅游必备物品、成都出境旅行、出国旅游团、出境旅游手续、国外热门旅游路线等出境旅游资讯与咨询服务\"";
            this.Hlable = "成都到马尔代夫旅游价格,成都出境旅游网,成都出发境外旅游,成都出发美国旅游,东南亚旅游,欧洲旅游";
        }

    }
}
